package rocket

import mq_http_sdk "github.com/aliyunmq/mq-http-go-sdk"

type (
	pusher struct {
		producer    mq_http_sdk.MQProducer
		Tag         string
		ShardingKey string
	}

	PusherConf struct {
		InstanceId  string
		Topic       string
		ShardingKey string
		Tag         string
	}
)

func (p *pusher) Name() string {
	return p.producer.TopicName()
}

func (p *pusher) Push(message string) error {
	msg := mq_http_sdk.PublishMessageRequest{
		MessageBody: message,
		MessageTag:  p.Tag,
		ShardingKey: p.ShardingKey,
	}
	_, err := p.producer.PublishMessage(msg)

	return err
}
